package com.cxhc.app.api.hcdoc;

import com.cxhc.app.api.hcdoc.vo.HdProjectInfoVo;
import com.cxhc.app.api.mapper.hcdoc.HdProjectInfoMapStructMapper;
import com.cxhc.common.core.controller.BaseController;
import com.cxhc.common.core.domain.AjaxResult;
import com.cxhc.common.core.page.TableDataInfo;
import com.cxhc.system.domain.hcdoc.HdProjectInfo;
import com.cxhc.system.service.hcdoc.HdProjectInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 项目信息Controller
 *
 * @author Dhq
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/api/hcDoc/hdProject")
public class HdProjectInfoApi extends BaseController {

    @Autowired
    private HdProjectInfoService hdProjectInfoService;

    /**
     * 获取项目信息详细信息 之后写
     */
    @RequestMapping(value = "/getInfoId")
    public AjaxResult getInfoId(String id) {
        return success(hdProjectInfoService.selectById(id));
    }

    /**
     * 新增项目信息
     */
    @RequestMapping("/insert")
    @ResponseBody
    public AjaxResult insert(@RequestBody HdProjectInfoVo hdProjectInfoVo) {
        HdProjectInfo hdProjectInfo = HdProjectInfoMapStructMapper.INSTANCE.HdProjectInfoVoToHdProjectInfo(hdProjectInfoVo);
        return toAjax(hdProjectInfoService.insertHdProjectInfo(hdProjectInfo));
    }

    /**
     * 查询项目信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(HdProjectInfoVo hdProjectInfoVo) {
        HdProjectInfo hdProjectInfo = HdProjectInfoMapStructMapper.INSTANCE.HdProjectInfoVoToHdProjectInfo(hdProjectInfoVo);
        startPage();
        return getDataTable(hdProjectInfoService.selectList(hdProjectInfo));
    }

    /**
     * 更新项目信息信息
     */
    @PostMapping("/update")
    public AjaxResult update(@RequestBody HdProjectInfoVo hdProjectInfoVo) {
        HdProjectInfo hdProjectInfo = HdProjectInfoMapStructMapper.INSTANCE.HdProjectInfoVoToHdProjectInfo(hdProjectInfoVo);
        return toAjax(hdProjectInfoService.update(hdProjectInfo));
    }

    /**
     * 更新项目信息信息
     */
    @GetMapping("/delete")
    public AjaxResult delete(String id) {
        return toAjax(hdProjectInfoService.delete(id));
    }

}
